package exer;

/**
 * @author shkstart
 * @create 2022-08-15-17:02
 */
public class mian0207 {
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {

        ListNode pA = headA;
        ListNode pB = headB;
        while (pA != pB) {
            if (pA != null) {
                pA = pA.next;
            }else{
                pA = headB;
            }
            if (pB != null) {
                pB = pB.next;
            }else{
                pB = headA;
            }

        }
        if(pB==null){
            return  null;
        }else {
            return pA;
        }


    }
}
